<?php
require_once '../../global.inc.php';

$fileName = $_GET["n"];
$filePath = $_GET["p"];

download($fileName, $filePath);

function download($fileName,$filePath){
	if (!file_exists($filePath)){
		header("Content-type: text/html; charset=utf-8");
		echo "<script>alert('没有找到文件!');</script>";
		exit;
	} else {
		$file = fopen($filePath,"r");
		Header("Content-type: application/octet-stream");
		Header("Accept-Ranges: bytes");
		Header("Accept-Length: ".filesize($filePath));
		Header("Content-Disposition: attachment; filename=".$fileName);
		echo fread($file, filesize($filePath));
		fclose($file);
	}
}
?>